<template>
    <div>
        <table>
            <tbody>
                <tr>
                    <td>房型名称</td>
                    <td>
                        <input type="text" v-model="data.fxmc">
                    </td>
                </tr>
                <tr>
                    <td>门市销售价格</td>
                    <td>
                        <input type="text" v-model="data.jg">
                    </td>
                </tr>
                <tr>
                    <td>房间数</td>
                    <td>
                        <input type="text" v-model="data.fjs">
                    </td>
                </tr>
                <tr>
                    <td>状态</td>
                    <td>
                        状态:   <input type="radio" name="1" v-model="data.zt" value="true" >启用
                        <input type="radio" name="1"  v-model="data.zt" value="false" >停用
                    </td>
                </tr>
                <tr>
                    <td>房间号</td>
                    <td>
                        <input type="checkbox"   v-for="w in sert":value="w" v-model="data.fjh" >
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="修改" @click="xg"  >
                    </td>
                </tr>
            </tbody>
        </table>

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted } from 'vue';
import { useRoute } from 'vue-router';

const stre = useRoute();


const sert = ref([1021,1024,1025,1026,1027,1028,1029,1030])

const data=ref({
    "id": 0,
  "fxmc": "",
  "jg": 0,
  "fjs": 0,
  "zt": true,
  "fjh": "string",
  "sc": true
})

const  xg=()=>{
        if(data.value.fxmc==""){
            alert("房间名称不能为空");
            return
        }
        if(data.value.jg<0){
            alert("价格不能小于0");
            return
        }


    axios.post("https://localhost:7029/api/we/update",data.value).then(res=>{
        if(res.data>0){
            alert("修改成功")
            location.href="/"
        }else{
            alert("修改失败")
        }
    })
}
onMounted(()=>{
    xs();
})
const xs=()=>{
    var vid = stre.query.id
    axios.get("https://localhost:7029/api/we/xss",{params:{id:vid}}).then(res=>{
        data.value=res.data

     
    })
}

</script>

<style scoped>

</style>